<!-- 文件名：cart.html -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head><title>购物车</title></head>
<body>
<h2>购物车</h2>

<div th:if="${cartExists}">
  <table border="1px">
    <tr><th>商品名</th><th>价格</th></tr>
    <tr th:each="product : ${products}">
      <td th:text="${product.name}"></td>
      <td th:text="${product.price}"></td>
    </tr>
  </table>
  <form th:action="@{'/cart/submit?username=' + ${username}}" method="post">
    <button type="submit">提交订单</button>
  </form>
</div>

<div th:if="${!cartExists}">
  当前没有商品在购物车中。
</div>
</body>
</html>
